package com.zhj.helloframework.mvc.render.impl;

import com.zhj.helloframework.mvc.RequestProcessorChain;
import com.zhj.helloframework.mvc.render.ResultRender;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author: zhj
 * @Description: 资源未找到渲染器
 * @Date: 2021/11/16 15:54
 * @Version: 1.0
 */
public class ResourceNotFoundResultRender implements ResultRender {

    private String httpMethod;
    private String httpPath;

    public ResourceNotFoundResultRender(String httpMethod, String httpPath) {
        this.httpMethod = httpMethod;
        this.httpPath = httpPath;
    }

    @Override
    public void render(RequestProcessorChain requestProcessorChain) throws Exception {
        // 在response中设置资源找不到信息
        requestProcessorChain.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND,
                "获取不到对应的请求资源：请求路径[" + httpPath + "]，请求方法[" + httpMethod + "]");
    }
}
